<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
<#include "../common/header.ftl">
    <script src="/js/plugins/chosen/chosen.jquery.js"></script>
    <link rel="stylesheet" href="/js/plugins/chosen/component-chosen.css"/>
    <script>
        $(function () {
            //添加攻略分类按钮
            $("#addStrategyBtn").click(function () {
                $("#editForm")[0].reset();
                $("#strategyCatalogModal").modal("show");
            });
            //保存按钮
            $("#saveBtn").click(function () {
                $("#editForm").ajaxSubmit(function (data) {
                    showMessager(data);
                })
            })

            //获取所有的地区
            $.get("/strategy/listAll.do", function (data) {
                var html = "<option></option>";
                $.each(data, function (index, ele) {
                    html += "<option value='" + ele.id + "'>" + ele.title + "</option>";
                });
                $(".strategySelect").html(html);
                //回显下拉框选择条件
                $("#strategyQuery option[value=" + ${(qo.strategyId)!} +"]").prop('selected', true);
                //初始化组件
                $(".strategySelect").chosen({
                    placeholder_text_single: "请选择所属攻略",
                    disable_search_threshold: 10,//大于10条就显示搜索框
                    no_results_text: "无相关地区"//搜索时找不到的提示
                });
            })
        })
    </script>
</head>
<body>

<div class="container " style="margin-top: 20px">
<#include "../common/top.ftl">
    <div class="row">
        <div class="col-sm-3">
        <#include "../common/menu.ftl">
        </div>
        <div class="col-sm-9">
            <div class="row">
                <div class="col-sm-12">
                    <h1 class="page-head-line">攻略分类管理</h1>
                </div>
            </div>
            <!--高级查询-->
            <form class="form-inline" id="searchForm" action="/strategyTravel/list.do" method="post">
                <input type="hidden" name="currentPage" id="currentPage" value="1">
                <div class="form-group">
                    <label>攻略搜索:</label>
                    <select class="form-control strategySelect" id="strategyQuery" name="strategyId">
                    </select>
                </div>
                <div class="form-group">
                    <button id="btn_query" class="btn btn-success">查询</button>
                    <a href="javascript:void(-1);" class="btn btn-success" id="addStrategyBtn">添加关联</a>

                </div>
            </form>
            <table class="table table-striped table-hover">
                <thead>
                <tr>
                    <th>关联游记</th>
                </tr>
                <tr/>
                </thead>
            <#list result.list as entity>
                <tr>
                    <td>入住长隆熊猫酒店，天天都是儿童节</td>
                    <td>
                        <a href="/travel/list.do?id=2" target="_blank" >查看游记文章</a>
                    </td>
                    <td>
                        <a href="javascript:void(-1);" class="del_Btn" data-jsonstr='{"id":2,"title":"入住长隆熊猫酒店，天天都是儿童节"}'>删除</a>
                    </td>
                </tr>
                <tr>
                    <td>飞到羊城，只为一场最地道的早茶之旅</td>
                    <td>
                        <a href="/travel/list.do?id=1" target="_blank" >查看游记文章</a>
                    </td>
                    <td>
                        <a href="javascript:void(-1);" class="del_Btn" data-jsonstr='{"id":1,"title":"飞到羊城，只为一场最地道的早茶之旅"}'>删除</a>
                    </td>

                </tr>
            </#list>
            </table>
            <div style="text-align: center;">
                <ul id="pagination" class="pagination"></ul>
            </div>
        </div>
    </div>
</div>
<div class="modal fade" id="strategyCatalogModal" tabindex="-1" role="dialog">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title">攻略分类新增/编辑</h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal" action="/strategyCatalog/saveOrUpdate.do" method="post" id="editForm">
                    <input type="hidden" id="strategyCatalogId" name="id">
                    <div class="form-group">
                        <label for="name" class="col-sm-4 control-label">所属攻略：</label>
                        <div class="col-sm-6">
                            <select class="form-control strategySelect" name="strategy.id" id="strategyForm">
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="name" class="col-sm-4 control-label">关联游记：</label>
                        <div class="col-sm-6">
                            <input type="number" class="form-control" id="sequence" name="sequence">
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <button type="button" class="btn btn-success" id="saveBtn">保存</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div><!-- /.modal -->
</body>
</html>